﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace api_version.Controllers.v2
{
    //ApiVersionNeutral 特性定义此 API 不在支持版本控制。无论 支持api 版本控制或不支持 api 
     //版本控制的旧式 api，这对于行为完全相同的 api 非常有用
   // [ApiVersionNeutral]
    [ApiVersion("2.0")]
     [Route("api/v{version:apiVersion}/[controller]")]
    //[Route("api/[controller]")]
    public class ValuesController : Controller
    {
        // GET api/values
        
        [HttpGet]
        public string Get()
        {
            //return "this is api version 2.0";
            return HttpContext.GetRequestedApiVersion().ToString();
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}
